import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

import Procurement from "@/views/procurement";
import User from "@/views/procurement/user";
import UserInformation from "@/views/procurement/user/userInformation";
import enterpriseInformation from "@/views/procurement/user/enterpriseInformation"
import targetList from "@/views/procurement/user/targetList"
import bidList from "@/views/procurement/user/bidList"

import platform from "@/views/procurement/plantform"
import plantformdetail from "@/views/procurement/plantform/plantformdetail"
import informationnotice from '@/views/procurement/informationnotice'
import infnoticedetail from "@/views/procurement/informationnotice/infnoticedetail"
import policylaw from "@/views/procurement/policylaw"
import policylawdetail from "@/views/procurement/policylaw/policylawdetail"
import inobserverule from "@/views/procurement/inobserverule"
import inobserveresult from "@/views/procurement/inobserverule/inobserveresult"
/* Router Modules */
export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  {
    path: "/",
    component: () => import("@/layout/procurement"),
    name: "procurement",
    redirect: "index",
    children: [
      // 首页
      {
        path: "/index",
        name: "index",
        component: Procurement,
      },
      // 平台动态
      {
        path:"/platform",
        name:"platform",
        component:platform
      },
      //平台动态详情页
      {
        path:'/plantformdetail',
        name:'plantformdetail',
        component:plantformdetail
      },
      // 信息公告
      {
        path:"/informationnotice",
        name:"informationnotice",
        component:informationnotice
      },
      //信息公告详情页
      {
        path:'/infnoticedetail',
        name:'infnoticedetail',
        component:infnoticedetail
      },
      // 政策法规
      {
        path:"/policylaw",
        name:"policylaw",
        component:policylaw
      },
      // 政策法规详情页
      {
        path:"/policylawdetail",
        name:"policylawdetail",
        component:policylawdetail
      },
      // 违规投诉
      {
        path:"/inobserverule",
        name:'inobserverule',
        component:inobserverule
      },
      // 违规投诉结果详情页
      {
        path:"/inobserveresult",
        name:"inobserveresult",
        component:inobserveresult
      },
      // 用户中心
      {
        path: "/user",
        name: "user",
        component: User,
        children: [
          // 用户中心
          {
            path: "/userInformation",
            name: "userInformation",
            component: UserInformation,
          },
          // 企业信息
          {
            path: "/enterpriseInformation",
            name: "enterpriseInformation",
            component: enterpriseInformation,
          },
          // 我的投标
          {
            path: "/targetList",
            name: "targetList",
            component: targetList,
          },
          // 参与投标
          {
            path: "/bidList",
            name: "bidList",
            component: bidList,
          },
        ]
      }
    ],
  },
  {
    path: "/applylicense",
    component: (resolve) => require(["@/views/applylicense"], resolve),
    hidden: true,
  },
];

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [{ path: "*", redirect: "/404", hidden: true }];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
